package com.spgf.control.models;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.archtecture.control.models.ModelAb;

/**
 * The persistent class for the banco database table.
 * 
 */
@Entity
@Table(name = "banco")
public class Banco extends ModelAb implements Serializable {

	/**
	 * 
	 */
	private static final long	serialVersionUID	= -5713272038377529784L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "CODIGO")
	private Integer				codigo;

	@Column(name = "NOME")
	private String				nome;

	@Column(name = "SALDO")
	private Double				saldo;

	// bi-directional many-to-one association to Lancamento
	@OneToMany(mappedBy = "banco")
	private List<Lancamento>	lancamentos;

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (!(obj instanceof Banco)) {
			return false;
		}
		Banco other = (Banco) obj;
		if (codigo == null) {
			if (other.codigo != null) {
				return false;
			}
		} else if (!codigo.equals(other.codigo)) {
			return false;
		}
		return true;
	}

	@Override
	public String[] getAtributosOrdencao() {
		return new String[] {"codigo"};
	}

	@Override
	public Integer getCodigo() {
		return codigo;
	}

	/**
	 * @return the lancamentos
	 */
	public List<Lancamento> getLancamentos() {
		return lancamentos;
	}

	/**
	 * @return the nome
	 */
	public String getNome() {
		return nome;
	}

	/**
	 * @return the saldo
	 */
	public Double getSaldo() {
		return saldo;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((codigo == null) ? 0 : codigo.hashCode());
		return result;
	}

	public void setCodigo(Integer codigo) {
		this.codigo = codigo;
	}

	/**
	 * @param lancamentos
	 *            the lancamentos to set
	 */
	public void setLancamentos(List<Lancamento> lancamentos) {
		this.lancamentos = lancamentos;
	}

	/**
	 * @param nome
	 *            the nome to set
	 */
	public void setNome(String nome) {
		this.nome = nome;
	}

	/**
	 * @param saldo
	 *            the saldo to set
	 */
	public void setSaldo(Double saldo) {
		this.saldo = saldo;
	}

}